﻿@model List<Demo.Model.EntityModels.Person>

@using DevExpress.Web.Mvc.UI;
@using DevExpress.Web.Mvc;
@using System.Web.UI.WebControls;

@Html.DevExpress().GridView(
    settings =>
    {
        settings.Name = "dxGridView";
		
        settings.KeyFieldName = "id";
		
        settings.CallbackRouteValues = new { Controller = "Person", Action = "ListGridPartialView" };
        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);

       
        
        settings.Columns.Add("name");
		
        settings.Columns.Add(column =>
        {
            column.Caption = "#";
            column.SetDataItemTemplateContent(c =>
            {
                ViewContext.Writer.Write(
					
                    Html.ActionLink("Edit", "Edit", new RouteValueDictionary {  {"id", DataBinder.Eval(c.DataItem, "id")} }) + "&nbsp" +
                    Html.ActionLink("Delete", "Delete", new RouteValueDictionary {  {"id", DataBinder.Eval(c.DataItem, "id")} },
                        new Dictionary<string, object> { { "onclick", "return confirm('Are you sure you want to delete this item?')" } })
                );
            });
            column.SetHeaderTemplateContent(c =>
            {
                ViewContext.Writer.Write(
                    Html.ActionLink("New", "Edit", new RouteValueDictionary {  {"id", default(int) } }).ToHtmlString()
                );
            });
            column.Settings.AllowDragDrop = DefaultBoolean.False;
            column.Settings.AllowSort = DefaultBoolean.False;
            column.Width = 70;
        });

        settings.SettingsPager.Position = System.Web.UI.WebControls.PagerPosition.Bottom;
        settings.SettingsPager.FirstPageButton.Visible = true;
        settings.SettingsPager.LastPageButton.Visible = true;
}).Bind(Model).GetHtml()
